#include "boundingbox.h"

BoundingBox::BoundingBox()
{
    m_localCenter = vec3(0,0,0);
    m_globalCenter = vec3(0,0,0);
    m_halfWidth = vec3(0,0,0);
}
void BoundingBox::setLocalCenter(const vec3 center)
{
    m_localCenter = center;
}
void BoundingBox::setGlobalCenter(const vec3 center)
{
    m_globalCenter = center;
}
void BoundingBox::setPosition(const vec3 pos)
{
    m_globalCenter = pos + m_localCenter;
}
void BoundingBox::setHalfWidth(const vec3 halfWidth)
{
    m_halfWidth = halfWidth;
}
vec3 BoundingBox::getLocalCenter()
{
    return m_localCenter;
}
vec3 BoundingBox::getGlobalCenter()
{
    return m_globalCenter;
}
vec3 BoundingBox::getHalfWidth()
{
    return m_halfWidth;
}
void BoundingBox::translate(vec3 t)
{
    m_globalCenter += t;
}



bool BoundingBox::testIntersection(vec3 centerB, vec3 halfWidthB)
{
    //////////////////////////////////////////////////// TODO Start

    vec3 centerA = m_globalCenter;
    vec3 halfWidthA = m_halfWidth;

    if(abs(centerB.x - centerA.x) < (halfWidthA.x + halfWidthB.x))
        return true;
    if(abs(centerB.y - centerA.y) < (halfWidthA.y + halfWidthB.y))
        return true;
    if(abs(centerB.z - centerA.z) < (halfWidthA.z + halfWidthB.z))
        return true;


    return false;

    //////////////////////////////////////////////////// TODO End
}

